<template>
<div class="we-chat-template views-container">
    <div class="wlm-table">
        <div class="wlm-table-hearder-btn">
            <router-link tag="span" to="/application/weChatTemplateAdd">
                <el-button size="small" type="primary">添加模板</el-button>
            </router-link>
        </div>
        <!-- <div class="wlm-table-header">
            <el-form :model="tableFormatData.userTable.files" size="small" label-width="85px" class="retail-form" label-position="right">
                <el-form-item label="" class="filter">
                    <el-form-item label="模板名称：">
                        <el-input v-model="tableFormatData.userTable.files.luck_title" placeholder="请输入模板名称" style="width:160px;"></el-input>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div> -->
        <div class="wlm-table-content">
            <el-table :ref="tableFormatData.userTable.key" :data="tableFormatData.userTable.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <!-- <el-table-column type="selection" width="55">
                </el-table-column> -->
                <el-table-column prop="date" label="模板ID"  min-width="60">
                    <template slot-scope="scope">
                        <span>{{scope.row.template_id}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="模板名称"  min-width="45">
                    <template slot-scope="scope">
                        <span>{{scope.row.name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="短信内容"  min-width="45">
                    <template slot-scope="scope">
                        <span>{{scope.row.template_content}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="状态"  min-width="80">
                    <template slot-scope="scope">
                        <span v-if="scope.row.is_open==10">启用</span>
                        <span v-if="scope.row.is_open==20">禁用</span>
                    </template>
                </el-table-column>
                <el-table-column label="创建时间"  min-width="45">
                    <template slot-scope="scope">
                        <p>{{scope.row.create_time}}</p>
                    </template>
                </el-table-column>
                <el-table-column label="操作" >
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <router-link class="wlm-text" tag="span" :to="{path:'/application/weChatTemplateAdd', query :{ id:scope.row.id}}">
                                <el-button type="text">编辑</el-button>
                            </router-link>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="scope.row.is_open = scope.row.is_open === 10 ? 20 : 10;changeTableItem({id:scope.row.id,is_open:scope.row.is_open},tableFormatData.userTable.change.card_cancel,{isWarning: scope.row.is_open === 20,warning:'是否确认禁用？',cancel:{msg:'已取消禁用',val:{scope:scope,cancelStatus:{key:'is_open',val:10}}}})">{{scope.row.is_open === 10 ? '禁用':'启用'}}</el-button>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-content flex-row flex-justify-e flex-align-c">
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.userTable.pagination.page" :page-sizes="tableFormatData.userTable.pagination.pagesizes" :page-size.sync="tableFormatData.userTable.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.userTable.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  getDataList,
  delSmsData,
  getOpenStatus
} from '@/api/application'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'WeChatTemplate',
  components: {
  },
  data() {
    return {
      blogTitle: '',
      tableFormatData: {
        current: 'userTable',
        userTable: {
          key: 'userTable',
          api: {
            getList: getDataList,
            delList: delSmsData
            // msgConfig: {
            //   del: {
            //     type: 'warning',
            //     msg: '删除卡密库，对应的商品将做售罄或下架处理，确认删除此卡密库？'
            //   }
            // }
          },
          tableData: [],
          files: {
            ids: [],
            checkall: '0',
            Recycle: '1',
            res: 1
          },
          change: {
            card_cancel: {
              key: 'card_cancel',
              api: getOpenStatus
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {
  }
}
</script>
